 Imports MySql.Data.MySqlClient 
 Imports System.Data.OleDb
Imports System.Data.SqlClient
 Imports System .Data .SqlServerCe 
 Imports System.Data.OracleClient 
Imports System.Data
Imports DTO
Public Class CTGIANGDAYDao
Inherits AbstractDao
 #Region "New" 
 Public Sub New(ByVal connection As KetNoiDto)
 MyBase.New(connection)
 End Sub
 Public Sub New( ByVal IDCTGIANGDAY As System.Int32, ByVal connection As KetNoiDto)
 MyBase.New("CTGIANGDAY", "select * from CTGIANGDAY where IDCTGIANGDAY=" & IDCTGIANGDAY & "", connection)
 End Sub
 #End Region 
 Public Sub Them(ByVal Dto As CTGIANGDAYDto)
 Dim strsql As String
 strsql = "Insert into CTGIANGDAY(IDGIAOVIEN,IDLOPHOC,NGAYBATDAU,NGAYKETTHUC,TRANGTHAI,GHICHU) values (?,?,?,?,?,?)
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 Dim cmd As New OleDbCommand(strsql, Ket_noi_access)
cmd.Parameters.Add("@IDGIAOVIEN", OleDbType.Integer)
cmd.Parameters.Add("@IDLOPHOC", OleDbType.Integer)
cmd.Parameters.Add("@NGAYBATDAU", OleDbType.Date)
cmd.Parameters.Add("@NGAYKETTHUC", OleDbType.Date)
cmd.Parameters.Add("@TRANGTHAI", OleDbType.Integer)
cmd.Parameters.Add("@GHICHU", OleDbType.VarWChar)
cmd.Parameters("@IDGIAOVIEN").Value = Dto.IDGIAOVIEN
cmd.Parameters("@IDLOPHOC").Value = Dto.IDLOPHOC
cmd.Parameters("@NGAYBATDAU").Value = Dto.NGAYBATDAU
cmd.Parameters("@NGAYKETTHUC").Value = Dto.NGAYKETTHUC
cmd.Parameters("@TRANGTHAI").Value = Dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = Dto.GHICHU
 cmd.ExecuteNonQuery()
 strsql = "Select @@IDENTITY"
 cmd = New OleDbCommand(strsql, Ket_noi_access)
 Dto.IDCTGIANGDAY = cmd.ExecuteScalar()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress
 strsql = "Insert into CTGIANGDAY(IDGIAOVIEN,IDLOPHOC,NGAYBATDAU,NGAYKETTHUC,TRANGTHAI,GHICHU) values (@IDGIAOVIEN,@IDLOPHOC,@NGAYBATDAU,@NGAYKETTHUC,@TRANGTHAI,@GHICHU)
 Dim cmd As New sqlCommand(strsql, Ket_noi_sql)
cmd.Parameters.Add("@IDGIAOVIEN", SqlDbType.Int)
cmd.Parameters.Add("@IDLOPHOC", SqlDbType.Int)
cmd.Parameters.Add("@NGAYBATDAU", SqlDbType.DateTime)
cmd.Parameters.Add("@NGAYKETTHUC", SqlDbType.DateTime)
cmd.Parameters.Add("@TRANGTHAI", SqlDbType.Int)
cmd.Parameters.Add("@GHICHU", SqlDbType.NVarChar)
cmd.Parameters("@IDGIAOVIEN").Value = Dto.IDGIAOVIEN
cmd.Parameters("@IDLOPHOC").Value = Dto.IDLOPHOC
cmd.Parameters("@NGAYBATDAU").Value = Dto.NGAYBATDAU
cmd.Parameters("@NGAYKETTHUC").Value = Dto.NGAYKETTHUC
cmd.Parameters("@TRANGTHAI").Value = Dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = Dto.GHICHU
 cmd.ExecuteNonQuery()
 strsql = "Select @@IDENTITY"
 cmd = New sqlCommand(strsql, Ket_noi_sql)
 Dto.IDCTGIANGDAY = cmd.ExecuteScalar()
 Case Class_KieuDL.SqlCe
 strsql = "Insert into CTGIANGDAY(IDGIAOVIEN,IDLOPHOC,NGAYBATDAU,NGAYKETTHUC,TRANGTHAI,GHICHU) values (@IDGIAOVIEN,@IDLOPHOC,@NGAYBATDAU,@NGAYKETTHUC,@TRANGTHAI,@GHICHU)
 Dim cmd As New sqlceCommand(strsql, Ket_noi_SqlCe)
cmd.Parameters("@IDGIAOVIEN").Value = Dto.IDGIAOVIEN
cmd.Parameters("@IDLOPHOC").Value = Dto.IDLOPHOC
cmd.Parameters("@NGAYBATDAU").Value = Dto.NGAYBATDAU
cmd.Parameters("@NGAYKETTHUC").Value = Dto.NGAYKETTHUC
cmd.Parameters("@TRANGTHAI").Value = Dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = Dto.GHICHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strsql = "Insert into CTGIANGDAY(IDGIAOVIEN,IDLOPHOC,NGAYBATDAU,NGAYKETTHUC,TRANGTHAI,GHICHU) values (@IDGIAOVIEN,@IDLOPHOC,@NGAYBATDAU,@NGAYKETTHUC,@TRANGTHAI,@GHICHU)
 Dim cmd As New OracleCommand(strsql, Ket_noi_Oracle)
cmd.Parameters("@IDGIAOVIEN").Value = Dto.IDGIAOVIEN
cmd.Parameters("@IDLOPHOC").Value = Dto.IDLOPHOC
cmd.Parameters("@NGAYBATDAU").Value = Dto.NGAYBATDAU
cmd.Parameters("@NGAYKETTHUC").Value = Dto.NGAYKETTHUC
cmd.Parameters("@TRANGTHAI").Value = Dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = Dto.GHICHU
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Mysql
 strsql = "Insert into CTGIANGDAY(IDGIAOVIEN,IDLOPHOC,NGAYBATDAU,NGAYKETTHUC,TRANGTHAI,GHICHU) values (@IDGIAOVIEN,@IDLOPHOC,@NGAYBATDAU,@NGAYKETTHUC,@TRANGTHAI,@GHICHU)
 Dim cmd As New MySqlCommand(strsql, Ket_noi_MySql)
cmd.Parameters.Add("@IDGIAOVIEN", MySqlDbType.Int32)
cmd.Parameters.Add("@IDLOPHOC", MySqlDbType.Int32)
cmd.Parameters.Add("@NGAYBATDAU",  MySqlDbType.DateTime)
cmd.Parameters.Add("@NGAYKETTHUC",  MySqlDbType.DateTime)
cmd.Parameters.Add("@TRANGTHAI", MySqlDbType.Int32)
cmd.Parameters.Add("@GHICHU", MySqlDbType.String)
cmd.Parameters("@IDGIAOVIEN").Value = Dto.IDGIAOVIEN
cmd.Parameters("@IDLOPHOC").Value = Dto.IDLOPHOC
cmd.Parameters("@NGAYBATDAU").Value = Dto.NGAYBATDAU
cmd.Parameters("@NGAYKETTHUC").Value = Dto.NGAYKETTHUC
cmd.Parameters("@TRANGTHAI").Value = Dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = Dto.GHICHU
 cmd.ExecuteNonQuery()
 End Select
 Ngatketnoi()
 End Sub
 Public Sub Xoa( ByVal IDCTGIANGDAY As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
strSQL = "Delete From CTGIANGDAY Where IDCTGIANGDAY= ? 
Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
cmd.Parameters.Add("@IDCTGIANGDAY",OleDbType.Integer).Value = IDCTGIANGDAY
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
strSQL = "Delete From CTGIANGDAY Where IDCTGIANGDAY= @IDCTGIANGDAY
Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
cmd.Parameters.Add("@IDCTGIANGDAY",SqlDbType.Int).value=IDCTGIANGDAY
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
strSQL = "Delete From CTGIANGDAY Where IDCTGIANGDAY=" & IDCTGIANGDAY & "
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
strSQL = "Delete From CTGIANGDAY Where IDCTGIANGDAY=" & IDCTGIANGDAY & "
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
strSQL = "Delete From CTGIANGDAY Where IDCTGIANGDAY=" & IDCTGIANGDAY & "
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select
 Ngatketnoi()
 End Sub
 Public Sub sua(ByVal dto As CTGIANGDAYDto)
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update CTGIANGDAY Set IDGIAOVIEN=? ,IDLOPHOC=? ,NGAYBATDAU=? ,NGAYKETTHUC=? ,TRANGTHAI=? ,GHICHU= ? where IDCTGIANGDAY= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
cmd.Parameters.Add("@IDGIAOVIEN", OleDbType.Integer)
cmd.Parameters.Add("@IDLOPHOC", OleDbType.Integer)
cmd.Parameters.Add("@NGAYBATDAU", OleDbType.Date)
cmd.Parameters.Add("@NGAYKETTHUC", OleDbType.Date)
cmd.Parameters.Add("@TRANGTHAI", OleDbType.Integer)
cmd.Parameters.Add("@GHICHU", OleDbType.VarWChar)
cmd.Parameters.Add("@IDCTGIANGDAY", OleDbType.Integer)
cmd.Parameters("@IDGIAOVIEN").Value = dto.IDGIAOVIEN
cmd.Parameters("@IDLOPHOC").Value = dto.IDLOPHOC
cmd.Parameters("@NGAYBATDAU").Value = dto.NGAYBATDAU
cmd.Parameters("@NGAYKETTHUC").Value = dto.NGAYKETTHUC
cmd.Parameters("@TRANGTHAI").Value = dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = dto.GHICHU
cmd.Parameters("@IDCTGIANGDAY").Value = dto.IDCTGIANGDAY
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update CTGIANGDAY Set IDGIAOVIEN= @IDGIAOVIEN , IDLOPHOC= @IDLOPHOC , NGAYBATDAU= @NGAYBATDAU , NGAYKETTHUC= @NGAYKETTHUC , TRANGTHAI= @TRANGTHAI , GHICHU= @GHICHU where IDCTGIANGDAY= @IDCTGIANGDAY"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
cmd.Parameters.Add("@IDGIAOVIEN", SqlDbType.Int)
cmd.Parameters.Add("@IDLOPHOC", SqlDbType.Int)
cmd.Parameters.Add("@NGAYBATDAU", SqlDbType.DateTime)
cmd.Parameters.Add("@NGAYKETTHUC", SqlDbType.DateTime)
cmd.Parameters.Add("@TRANGTHAI", SqlDbType.Int)
cmd.Parameters.Add("@GHICHU", SqlDbType.NVarChar)
cmd.Parameters.Add("@IDCTGIANGDAY", SqlDbType.Int)
cmd.Parameters("@IDGIAOVIEN").Value = dto.IDGIAOVIEN
cmd.Parameters("@IDLOPHOC").Value = dto.IDLOPHOC
cmd.Parameters("@NGAYBATDAU").Value = dto.NGAYBATDAU
cmd.Parameters("@NGAYKETTHUC").Value = dto.NGAYKETTHUC
cmd.Parameters("@TRANGTHAI").Value = dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = dto.GHICHU
cmd.Parameters("@IDCTGIANGDAY").Value = dto.IDCTGIANGDAY
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update CTGIANGDAY Set IDGIAOVIEN= @IDGIAOVIEN , IDLOPHOC= @IDLOPHOC , NGAYBATDAU= @NGAYBATDAU , NGAYKETTHUC= @NGAYKETTHUC , TRANGTHAI= @TRANGTHAI , GHICHU= @GHICHU where IDCTGIANGDAY= @IDCTGIANGDAY"
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
cmd.Parameters("@IDGIAOVIEN").Value = dto.IDGIAOVIEN
cmd.Parameters("@IDLOPHOC").Value = dto.IDLOPHOC
cmd.Parameters("@NGAYBATDAU").Value = dto.NGAYBATDAU
cmd.Parameters("@NGAYKETTHUC").Value = dto.NGAYKETTHUC
cmd.Parameters("@TRANGTHAI").Value = dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = dto.GHICHU
cmd.Parameters("@IDCTGIANGDAY").Value = dto.IDCTGIANGDAY
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update CTGIANGDAY Set IDGIAOVIEN= @IDGIAOVIEN , IDLOPHOC= @IDLOPHOC , NGAYBATDAU= @NGAYBATDAU , NGAYKETTHUC= @NGAYKETTHUC , TRANGTHAI= @TRANGTHAI , GHICHU= @GHICHU where IDCTGIANGDAY= @IDCTGIANGDAY"
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
cmd.Parameters("@IDGIAOVIEN").Value = dto.IDGIAOVIEN
cmd.Parameters("@IDLOPHOC").Value = dto.IDLOPHOC
cmd.Parameters("@NGAYBATDAU").Value = dto.NGAYBATDAU
cmd.Parameters("@NGAYKETTHUC").Value = dto.NGAYKETTHUC
cmd.Parameters("@TRANGTHAI").Value = dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = dto.GHICHU
cmd.Parameters("@IDCTGIANGDAY").Value = dto.IDCTGIANGDAY
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update CTGIANGDAY Set IDGIAOVIEN= @IDGIAOVIEN , IDLOPHOC= @IDLOPHOC , NGAYBATDAU= @NGAYBATDAU , NGAYKETTHUC= @NGAYKETTHUC , TRANGTHAI= @TRANGTHAI , GHICHU= @GHICHU where IDCTGIANGDAY= @IDCTGIANGDAY"
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
cmd.Parameters.Add("@IDGIAOVIEN", MySqlDbType.Int32)
cmd.Parameters.Add("@IDLOPHOC", MySqlDbType.Int32)
cmd.Parameters.Add("@NGAYBATDAU",  MySqlDbType.DateTime)
cmd.Parameters.Add("@NGAYKETTHUC",  MySqlDbType.DateTime)
cmd.Parameters.Add("@TRANGTHAI", MySqlDbType.Int32)
cmd.Parameters.Add("@GHICHU", MySqlDbType.String)
cmd.Parameters.Add("@IDCTGIANGDAY", MySqlDbType.Int32)
cmd.Parameters("@IDGIAOVIEN").Value = dto.IDGIAOVIEN
cmd.Parameters("@IDLOPHOC").Value = dto.IDLOPHOC
cmd.Parameters("@NGAYBATDAU").Value = dto.NGAYBATDAU
cmd.Parameters("@NGAYKETTHUC").Value = dto.NGAYKETTHUC
cmd.Parameters("@TRANGTHAI").Value = dto.TRANGTHAI
cmd.Parameters("@GHICHU").Value = dto.GHICHU
cmd.Parameters("@IDCTGIANGDAY").Value = dto.IDCTGIANGDAY
 cmd.ExecuteNonQuery()
 End Select
 Ngatketnoi()
 End Sub
 Public Sub SuaIDGIAOVIEN( ByVal IDGIAOVIEN as System.Int32, ByVal IDCTGIANGDAY As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update CTGIANGDAY Set IDGIAOVIEN = ?  where IDCTGIANGDAY= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@IDGIAOVIEN", OleDbType.Integer)
 cmd.Parameters.Add("@IDCTGIANGDAY", OleDbType.Integer)
 cmd.Parameters("@IDGIAOVIEN").Value =  IDGIAOVIEN
cmd.Parameters("@IDCTGIANGDAY").Value =  IDCTGIANGDAY
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update CTGIANGDAY Set IDGIAOVIEN = @IDGIAOVIEN  where IDCTGIANGDAY= @IDCTGIANGDAY"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@IDGIAOVIEN", SqlDbType.Int)
 cmd.Parameters.Add("@IDCTGIANGDAY", SqlDbType.Int)
 cmd.Parameters("@IDGIAOVIEN").Value =  IDGIAOVIEN
cmd.Parameters("@IDCTGIANGDAY").Value =  IDCTGIANGDAY
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update CTGIANGDAY Set IDGIAOVIEN =" & IDGIAOVIEN & "  where IDCTGIANGDAY=" & IDCTGIANGDAY & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update CTGIANGDAY Set IDGIAOVIEN =" & IDGIAOVIEN & "  where IDCTGIANGDAY=" & IDCTGIANGDAY & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update CTGIANGDAY Set IDGIAOVIEN =" & IDGIAOVIEN & "  where IDCTGIANGDAY=" & IDCTGIANGDAY & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaIDLOPHOC( ByVal IDLOPHOC as System.Int32, ByVal IDCTGIANGDAY As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update CTGIANGDAY Set IDLOPHOC = ?  where IDCTGIANGDAY= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@IDLOPHOC", OleDbType.Integer)
 cmd.Parameters.Add("@IDCTGIANGDAY", OleDbType.Integer)
 cmd.Parameters("@IDLOPHOC").Value =  IDLOPHOC
cmd.Parameters("@IDCTGIANGDAY").Value =  IDCTGIANGDAY
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update CTGIANGDAY Set IDLOPHOC = @IDLOPHOC  where IDCTGIANGDAY= @IDCTGIANGDAY"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@IDLOPHOC", SqlDbType.Int)
 cmd.Parameters.Add("@IDCTGIANGDAY", SqlDbType.Int)
 cmd.Parameters("@IDLOPHOC").Value =  IDLOPHOC
cmd.Parameters("@IDCTGIANGDAY").Value =  IDCTGIANGDAY
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update CTGIANGDAY Set IDLOPHOC =" & IDLOPHOC & "  where IDCTGIANGDAY=" & IDCTGIANGDAY & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update CTGIANGDAY Set IDLOPHOC =" & IDLOPHOC & "  where IDCTGIANGDAY=" & IDCTGIANGDAY & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update CTGIANGDAY Set IDLOPHOC =" & IDLOPHOC & "  where IDCTGIANGDAY=" & IDCTGIANGDAY & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaNGAYBATDAU( ByVal NGAYBATDAU as System.DateTime, ByVal IDCTGIANGDAY As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update CTGIANGDAY Set NGAYBATDAU = ?  where IDCTGIANGDAY= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@NGAYBATDAU", OleDbType.Date)
 cmd.Parameters.Add("@IDCTGIANGDAY", OleDbType.Integer)
 cmd.Parameters("@NGAYBATDAU").Value =  NGAYBATDAU
cmd.Parameters("@IDCTGIANGDAY").Value =  IDCTGIANGDAY
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update CTGIANGDAY Set NGAYBATDAU = @NGAYBATDAU  where IDCTGIANGDAY= @IDCTGIANGDAY"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@NGAYBATDAU", SqlDbType.DateTime)
 cmd.Parameters.Add("@IDCTGIANGDAY", SqlDbType.Int)
 cmd.Parameters("@NGAYBATDAU").Value =  NGAYBATDAU
cmd.Parameters("@IDCTGIANGDAY").Value =  IDCTGIANGDAY
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update CTGIANGDAY Set NGAYBATDAU =" & NGAYBATDAU & "  where IDCTGIANGDAY=" & IDCTGIANGDAY & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update CTGIANGDAY Set NGAYBATDAU =" & NGAYBATDAU & "  where IDCTGIANGDAY=" & IDCTGIANGDAY & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update CTGIANGDAY Set NGAYBATDAU =" & NGAYBATDAU & "  where IDCTGIANGDAY=" & IDCTGIANGDAY & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaNGAYKETTHUC( ByVal NGAYKETTHUC as System.DateTime, ByVal IDCTGIANGDAY As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update CTGIANGDAY Set NGAYKETTHUC = ?  where IDCTGIANGDAY= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@NGAYKETTHUC", OleDbType.Date)
 cmd.Parameters.Add("@IDCTGIANGDAY", OleDbType.Integer)
 cmd.Parameters("@NGAYKETTHUC").Value =  NGAYKETTHUC
cmd.Parameters("@IDCTGIANGDAY").Value =  IDCTGIANGDAY
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update CTGIANGDAY Set NGAYKETTHUC = @NGAYKETTHUC  where IDCTGIANGDAY= @IDCTGIANGDAY"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@NGAYKETTHUC", SqlDbType.DateTime)
 cmd.Parameters.Add("@IDCTGIANGDAY", SqlDbType.Int)
 cmd.Parameters("@NGAYKETTHUC").Value =  NGAYKETTHUC
cmd.Parameters("@IDCTGIANGDAY").Value =  IDCTGIANGDAY
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update CTGIANGDAY Set NGAYKETTHUC =" & NGAYKETTHUC & "  where IDCTGIANGDAY=" & IDCTGIANGDAY & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update CTGIANGDAY Set NGAYKETTHUC =" & NGAYKETTHUC & "  where IDCTGIANGDAY=" & IDCTGIANGDAY & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update CTGIANGDAY Set NGAYKETTHUC =" & NGAYKETTHUC & "  where IDCTGIANGDAY=" & IDCTGIANGDAY & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaTRANGTHAI( ByVal TRANGTHAI as System.Int32, ByVal IDCTGIANGDAY As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update CTGIANGDAY Set TRANGTHAI = ?  where IDCTGIANGDAY= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@TRANGTHAI", OleDbType.Integer)
 cmd.Parameters.Add("@IDCTGIANGDAY", OleDbType.Integer)
 cmd.Parameters("@TRANGTHAI").Value =  TRANGTHAI
cmd.Parameters("@IDCTGIANGDAY").Value =  IDCTGIANGDAY
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update CTGIANGDAY Set TRANGTHAI = @TRANGTHAI  where IDCTGIANGDAY= @IDCTGIANGDAY"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@TRANGTHAI", SqlDbType.Int)
 cmd.Parameters.Add("@IDCTGIANGDAY", SqlDbType.Int)
 cmd.Parameters("@TRANGTHAI").Value =  TRANGTHAI
cmd.Parameters("@IDCTGIANGDAY").Value =  IDCTGIANGDAY
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update CTGIANGDAY Set TRANGTHAI =" & TRANGTHAI & "  where IDCTGIANGDAY=" & IDCTGIANGDAY & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update CTGIANGDAY Set TRANGTHAI =" & TRANGTHAI & "  where IDCTGIANGDAY=" & IDCTGIANGDAY & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update CTGIANGDAY Set TRANGTHAI =" & TRANGTHAI & "  where IDCTGIANGDAY=" & IDCTGIANGDAY & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub SuaGHICHU( ByVal GHICHU as System.String, ByVal IDCTGIANGDAY As System.Int32 )
 Dim strSQL As String
 Moketnoi()
 select case ketnoi.MSsql 
 Case Class_KieuDL.Access
 strSQL = "Update CTGIANGDAY Set GHICHU = ?  where IDCTGIANGDAY= ? "
 Dim cmd As New OleDbCommand(strSQL, Ket_noi_access)
 cmd.Parameters.Add("@GHICHU", OleDbType.VarWChar)
 cmd.Parameters.Add("@IDCTGIANGDAY", OleDbType.Integer)
 cmd.Parameters("@GHICHU").Value =  GHICHU
cmd.Parameters("@IDCTGIANGDAY").Value =  IDCTGIANGDAY
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Sql,Class_KieuDL.sqlExpress 
 strSQL = "Update CTGIANGDAY Set GHICHU = @GHICHU  where IDCTGIANGDAY= @IDCTGIANGDAY"
 Dim cmd As New sqlCommand(strSQL, Ket_noi_sql)
 cmd.Parameters.Add("@GHICHU", SqlDbType.NVarChar)
 cmd.Parameters.Add("@IDCTGIANGDAY", SqlDbType.Int)
 cmd.Parameters("@GHICHU").Value =  GHICHU
cmd.Parameters("@IDCTGIANGDAY").Value =  IDCTGIANGDAY
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.SqlCe
 strSQL = "Update CTGIANGDAY Set GHICHU =" & GHICHU & "  where IDCTGIANGDAY=" & IDCTGIANGDAY & ""
 Dim cmd As New SqlCeCommand(strSQL, Ket_noi_SqlCe)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.Oracle
 strSQL = "Update CTGIANGDAY Set GHICHU =" & GHICHU & "  where IDCTGIANGDAY=" & IDCTGIANGDAY & ""
 Dim cmd As New OracleCommand(strSQL, Ket_noi_Oracle)
 cmd.ExecuteNonQuery()
 Case Class_KieuDL.MySql
 strSQL = "Update CTGIANGDAY Set GHICHU =" & GHICHU & "  where IDCTGIANGDAY=" & IDCTGIANGDAY & ""
 Dim cmd As New MySqlCommand(strSQL, Ket_noi_MySql)
 cmd.ExecuteNonQuery()
 End Select 
 Ngatketnoi()
 End Sub
 Public Sub layBang()
 Chuoi_SQL = " Select * from CTGIANGDAY
 Doc_bang()
 End Sub
 Public Sub layBangTheoIDCTGIANGDAY(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "IDCTGIANGDAY=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from CTGIANGDAY" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoIDCTGIANGDAY(ByVal IDCTGIANGDAY As System.Int32 )
 Chuoi_SQL = " Select * from CTGIANGDAY where  IDCTGIANGDAY = " & IDCTGIANGDAY & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoIDCTGIANGDAY(ByVal IDCTGIANGDAY As System.Int32)
 Dim strsql As String
 strSQL = "Delete From CTGIANGDAY Where IDCTGIANGDAY=" & IDCTGIANGDAY & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoIDGIAOVIEN(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "IDGIAOVIEN=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from CTGIANGDAY" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoIDGIAOVIEN(ByVal IDGIAOVIEN As System.Int32 )
 Chuoi_SQL = " Select * from CTGIANGDAY where  IDGIAOVIEN = " & IDGIAOVIEN & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoIDGIAOVIEN(ByVal IDGIAOVIEN As System.Int32)
 Dim strsql As String
 strSQL = "Delete From CTGIANGDAY Where IDGIAOVIEN=" & IDGIAOVIEN & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoIDLOPHOC(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "IDLOPHOC=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from CTGIANGDAY" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoIDLOPHOC(ByVal IDLOPHOC As System.Int32 )
 Chuoi_SQL = " Select * from CTGIANGDAY where  IDLOPHOC = " & IDLOPHOC & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoIDLOPHOC(ByVal IDLOPHOC As System.Int32)
 Dim strsql As String
 strSQL = "Delete From CTGIANGDAY Where IDLOPHOC=" & IDLOPHOC & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoNGAYBATDAU(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "NGAYBATDAU='" & ARRAY1.Item(i) & "'"
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from CTGIANGDAY" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoNGAYBATDAU(ByVal NGAYBATDAU As System.DateTime )
 Chuoi_SQL = " Select * from CTGIANGDAY where  NGAYBATDAU = @Ngay
 Doc_bang_Dk_ngay(NGAYBATDAU)
 End Sub
 Public Sub layBangTheoNGAYBATDAU(ByVal NGAYBATDAU1 As System.DateTime,ByVal NGAYBATDAU2 As System.DateTime )
 Chuoi_SQL = " Select * from CTGIANGDAY where  NGAYBATDAU >= @Ngay and NGAYBATDAU <= @denNgay ORDER BY NGAYBATDAU
 Doc_bang_Dk_ngay(NGAYBATDAU1,NGAYBATDAU2)
 End Sub
 Public Sub XOABangTheoNGAYBATDAU(ByVal NGAYBATDAU As System.DateTime)
 Dim strsql As String
 strSQL = "Delete From CTGIANGDAY Where NGAYBATDAU='" & NGAYBATDAU & "'"
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoNGAYKETTHUC(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "NGAYKETTHUC='" & ARRAY1.Item(i) & "'"
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from CTGIANGDAY" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoNGAYKETTHUC(ByVal NGAYKETTHUC As System.DateTime )
 Chuoi_SQL = " Select * from CTGIANGDAY where  NGAYKETTHUC = @Ngay
 Doc_bang_Dk_ngay(NGAYKETTHUC)
 End Sub
 Public Sub layBangTheoNGAYKETTHUC(ByVal NGAYKETTHUC1 As System.DateTime,ByVal NGAYKETTHUC2 As System.DateTime )
 Chuoi_SQL = " Select * from CTGIANGDAY where  NGAYKETTHUC >= @Ngay and NGAYKETTHUC <= @denNgay ORDER BY NGAYKETTHUC
 Doc_bang_Dk_ngay(NGAYKETTHUC1,NGAYKETTHUC2)
 End Sub
 Public Sub XOABangTheoNGAYKETTHUC(ByVal NGAYKETTHUC As System.DateTime)
 Dim strsql As String
 strSQL = "Delete From CTGIANGDAY Where NGAYKETTHUC='" & NGAYKETTHUC & "'"
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoTRANGTHAI(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "TRANGTHAI=" & ARRAY1.Item(i) & ""
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from CTGIANGDAY" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoTRANGTHAI(ByVal TRANGTHAI As System.Int32 )
 Chuoi_SQL = " Select * from CTGIANGDAY where  TRANGTHAI = " & TRANGTHAI & ""
 Doc_bang()
 End Sub
 Public Sub XOABangTheoTRANGTHAI(ByVal TRANGTHAI As System.Int32)
 Dim strsql As String
 strSQL = "Delete From CTGIANGDAY Where TRANGTHAI=" & TRANGTHAI & ""
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangTheoGHICHU(ByVal ARRAY1 As ArrayList)
 Dim DK As String = ""
 If ARRAY1.Count > 0 Then
 For I As Integer = 0 To ARRAY1.Count - 1
 DK = DK & IIf(DK <> "", " OR ", "") & "GHICHU='" & ARRAY1.Item(i) & "'"
 Next
 End If
 If DK <> "" Then DK = " WHERE " & DK 
 Chuoi_SQL = " Select * from CTGIANGDAY" & DK
 Doc_bang()
 End Sub
 Public Sub layBangTheoGHICHU_like (ByVal GHICHU As System.String )
 Chuoi_SQL = " Select * from CTGIANGDAY where  GHICHU  like '%" & GHICHU & "%'"
 Doc_bang()
 End Sub
 Public Sub layBangTheoGHICHU(ByVal GHICHU As System.String )
 Chuoi_SQL = " Select * from CTGIANGDAY where  GHICHU = '" & GHICHU & "'"
 Doc_bang()
 End Sub
 Public Sub XOABangTheoGHICHU(ByVal GHICHU As System.String)
 Dim strsql As String
 strSQL = "Delete From CTGIANGDAY Where GHICHU='" & GHICHU & "'"
 Thuc_hien_lenh(strsql)
 End Sub
 Public Sub layBangNhieuTable
 Chuoi_SQL = " Select IDCTGIANGDAY ,IDGIAOVIEN ,IDLOPHOC ,NGAYBATDAU ,NGAYKETTHUC ,TRANGTHAI ,GHICHU  from CTGIANGDAY"
 Doc_bang()
 End sub
Public Sub TaoTable()
Dim strsql As String
strsql = ""
Select Case ketnoi.MsSql
Case Class_KieuDL.Access 
Case Class_KieuDL.Sql, Class_KieuDL.sqlExpress
strsql = ""
Case Class_KieuDL.SqlCe
strsql = ""
Case Class_KieuDL.Oracle
strsql = ""
Case else 
strsql = ""
End Select
Thuc_hien_lenh(strsql)
End Sub
 End Class

